using System;
using UnityEngine;

public class KICOITBasicLogic : KICOITConsultant {

	public override void OnAwake () {
		base.OnAwake ();
		displayName = "KICOIT Basic Stats";
	}

	public override void AnalizePart (Part p, ShipData s) {
		//base.AnalizePart (p,s);
	}

	public override void DisplayUI (ShipData s) {
		//base.DisplayUI (s);
		
		GUIStyle sty = new GUIStyle (GUI.skin.label);
		sty.alignment = TextAnchor.UpperRight;
			
			
		GUILayout.BeginHorizontal (
				GUILayout.ExpandHeight (true),
				GUILayout.ExpandWidth (true)
		);
			
		GUILayout.BeginVertical (GUILayout.ExpandHeight (true));
		GUILayout.Label ("Stage");
		for (int i = 0; i <s.Count(); i++) {
			GUILayout.Label ("S " + i);
		}
		GUILayout.EndVertical ();
				
		GUILayout.BeginVertical (GUILayout.ExpandHeight (true));
		GUILayout.Label ("Cost");
		for (int i = 0; i <s.Count(); i++) {
			GUILayout.Label (
							s.getStage (i).cost.ToString () + "/" + s.getStage (i).totalCost.ToString (),
							sty
			);
		}
		GUILayout.EndVertical ();
				
		GUILayout.BeginVertical (GUILayout.ExpandHeight (true));
		GUILayout.Label ("Mass");
		
		for (int i = 0; i < s.Count(); i++) {
			GUILayout.Label (
							s.getStage (i).mass.ToString ("0.###") + " / " + s.getStage (i).totalWeight.ToString ("0.###"),
							sty
			);
		}
		GUILayout.EndVertical ();
				
		GUILayout.BeginVertical (GUILayout.ExpandHeight (true));
		GUILayout.Label ("RCS");
		for (int i = 0; i <s.Count(); i++) {
			GUILayout.Label (s.getStage (i).rcs.ToString ("0.###"), sty);
		}
		GUILayout.EndVertical ();
				
		GUILayout.BeginVertical (GUILayout.ExpandHeight (true));
		GUILayout.Label ("Fuel");
		for (int i = 0; i <s.Count(); i++) {
			GUILayout.Label (s.getStage (i).fuel.ToString ("0.###"), sty);
		}
		GUILayout.EndVertical ();
				
		GUILayout.BeginVertical (GUILayout.ExpandHeight (true));
		GUILayout.Label ("Thrust");
		for (int i = 0; i <s.Count(); i++) {
			if (s.getStage (i).thrust != 0 && s.getStage (i).airthrust != 0) {
				sty.normal.textColor = Color.yellow;//mixed
			} else if (s.getStage (i).airthrust != 0) {
				sty.normal.textColor = Color.green;//air
			} else {
				sty.normal.textColor = Color.white;//rockets
			}
						
			GUILayout.Label (
							(s.getStage (i).thrust + s.getStage (i).airthrust).ToString ("0.###"),
							sty
			);
						
		}
		GUILayout.EndVertical ();
		sty.normal.textColor = Color.white;
				
//		//start advanced stats
//		GUILayout.BeginVertical (GUILayout.ExpandHeight (true));
//		GUILayout.Label ("Kerbin/Mun TWR");
//		for (int i = 0; i <s.Count(); i++) {
//			if (s.getStage (i).thrust != 0 && s.getStage (i).airthrust != 0) {
//				sty.normal.textColor = Color.yellow;//mixed
//			} else if (s.getStage (i).airthrust != 0) {
//				sty.normal.textColor = Color.green;//air
//			} else {
//				sty.normal.textColor = Color.white;//rockets
//			}
//			if (s.getStage (i).thrust == 0 && s.getStage (i).airthrust == 0) {
//				GUILayout.Label ("-/-", sty);
//			} else {
//				float tw = s.getStage (i).thrust / s.getStage (i).totalWeight;
//				float ktw = (s.getStage (i).thrust + s.getStage (i).airthrust) / s.getStage (i).totalWeight;
//								
//				GUILayout.Label (
//							(ktw / 9.8068).ToString ("0.###") + " / " + (tw / 1.628).ToString ("0.###"),
//							sty
//				);
//			}
//		}
//		GUILayout.EndVertical ();
		GUILayout.EndHorizontal ();
	}
}


